package client.frm; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; import data.UserState; /** * 登录面板类。<br> */ public class LoginPane extends JFrame implements ActionListener{ private JLabel lblImg = new JLabel(); private JLabel lblJQNum = new JLabel("JQ账号"); private JComboBox boxJQNum = new JComboBox(); private JLabel lblPassword = new JLabel("JQ密码"); private JPasswordField pfPassword = new JPasswordField(); private JLabel lblState = new JLabel("状态:"); private JComboBox boxState = new JComboBox(); private JCheckBox boxAutoLogin = new JCheckBox("自动登录"); private JButton btnRegister = new JButton("申请账号"); private JButton btnSet = new JButton("设置↓"); private JButton btnLogin = new JButton("登录"); private JLabel lblServerIP = new JLabel("服务器IP:"); private JTextField txtServerIP = new JTextField("127.0.0.1"); private JLabel lblServerPort = new JLabel("端口:"); private JTextField txtServerPort = new JTextField("3608"); private boolean isSet = false; /** * 登陆窗体。 * */ public LoginPane() { setTitle("JQ用户登录"); setSize(324,235); setResizable(false); Toolkit tk=Toolkit.getDefaultToolkit(); setLocation((tk.getScreenSize().width-getSize().width)/2,(tk.getScreenSize().height-getSize().height)/2); setBackground(new Color(224,244,251)); init(); btnLogin.addActionListener(this); btnRegister.addActionListener(this); btnSet.addActionListener(this); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); } /** * 初始化登陆窗体的面板。 */ private void init(){ lblImg.setIcon(new ImageIcon(LoginPane.class.getResource("/client/images/top.gif"))); lblImg.setPreferredSize(new Dimension(325,47)); boxState.addItem(UserState.ONLINESTATE); boxState.addItem(UserState.HIDDENSTATE); boxState.addItem(UserState.DEPARTURESTATE); boxState.addItem(UserState.BUSYSTATE); boxState.setBackground(new Color(240,250,255)); boxState.setPreferredSize(new Dimension(60,20)); boxAutoLogin.setBackground(new Color(240,250,255)); boxJQNum.setEditable(true); boxJQNum.setPreferredSize(new Dimension(140,20)); pfPassword.setPreferredSize(new Dimension(140,20)); txtServerIP.setPreferredSize(new Dimension(80,20)); txtServerPort.setPreferredSize(new Dimension(50,20)); JPanel pane = new JPanel(); pane.setBackground(new Color(240,250,255)); pane.setBorder(new LineBorder(new Color(144,185,215))); pane.setLayout(new FlowLayout(FlowLayout.CENTER,15,12)); pane.setPreferredSize(new Dimension(300,110)); pane.add(new FillWidth(20,20,new Color(240,250,255))); pane.add(lblJQNum); pane.add(boxJQNum); pane.add(new FillWidth(20,20,new Color(240,250,255))); pane.add(new FillWidth(20,20,new Color(240,250,255))); pane.add(lblPassword); pane.add(pfPassword); pane.add(new FillWidth(20,20,new Color(240,250,255))); pane.add(lblState); pane.add(boxState); pane.add(boxAutoLogin); TitledBorder tb = new TitledBorder(new LineBorder(Color.GRAY),"网络设置"); JPanel paneSet = new JPanel(); paneSet.setPreferredSize(new Dimension(300,60)); paneSet.setBorder(tb); paneSet.add(lblServerIP); paneSet.add(txtServerIP); paneSet.add(new FillWidth(30,20)); paneSet.add(lblServerPort); paneSet.add(txtServerPort); setLayout(new FlowLayout(FlowLayout.CENTER,5,0)); add(lblImg); add(new FillWidth(100,8)); add(pane); add(new FillWidth(300,8)); add(btnRegister); add(btnSet); add(new FillWidth(65,20)); add(btnLogin); add(new FillWidth(300,8)); add(paneSet); } /** * 设置按钮、登陆按钮、注册按钮的事件。 */ public void actionPerformed(ActionEvent e) { if(e.getSource()==btnSet){ if(isSet){ isSet = false; setSize(getWidth(),getHeight()-65); btnSet.setText("设置↓"); }else{ isSet = true; setSize(getWidth(),getHeight()+65); btnSet.setText("设置↑"); } } if(e.getSource()==btnLogin){ dispose(); try{ new MainPane(txtServerIP.getText(),Integer.parseInt(txtServerPort.getText()),Integer.parseInt(boxJQNum.getSelectedItem().toString()),new String(pfPassword.getPassword()),((UserState)boxState.getSelectedItem()).getState()); }catch(Exception e1){ // pass } } if(e.getSource()==btnRegister){ dispose(); new RegisterPane(); } } public static void main(String[] args) { LoginPane login=new LoginPane(); } }
最近下载更多
小安同学 LV7
2023年12月25日
wertttak LV1
2023年9月26日
1748462964 LV1
2023年7月14日
2017143155 LV12
2023年6月24日
buhuia LV4
2023年6月9日
人工智能4708 LV11
2023年5月8日
liugua777 LV2
2023年5月4日
accp123456 LV2
2023年3月29日
yuanchuang LV22
2023年2月14日
ycycyc123 LV2
2022年12月9日
最近浏览更多
krispeng LV7
4月15日
3334004690 LV3
3月20日
yhwyhw1 LV2
1月2日
2890892945 LV2
2023年12月26日
Sutnuf
2023年11月27日
暂无贡献等级
Wsy2860 LV1
2023年9月6日
1748462964 LV1
2023年7月14日
13161895 LV1
2023年7月4日
fuyouou LV5
2023年6月29日
2017143155 LV12
2023年6月24日